part of '../../nl_photo_picker.dart';


enum ImageSource {
  /// Opens up the device camera, letting the user to take a new picture.
  camera,

  /// Opens the user's photo gallery.
  gallery,
}

class NlPhotoPicker {

  static const MethodChannel _channel =
  MethodChannel('nl_photo_picker');

  /// Returns a [File] object pointing to the image that was picked.
  ///
  /// The [source] argument controls where the image comes from. This can
  /// be either [ImageSource.camera] or [ImageSource.gallery].
  ///
  /// If specified, the image will be at most [maxWidth] wide and
  /// [maxHeight] tall. Otherwise the image will be returned at it's
  /// original width and height.
  static Future<String> pickImage({
    @required ImageSource source,
  }) async {
    assert(source != null);
    final String localIdentifier = await _channel.invokeMethod(
      'pickImage',
      <String, dynamic>{
        'source': source.index,
      },
    );

    return localIdentifier??null;
  }

  static Future<File> pickVideo({
    @required ImageSource source,
  }) async {
    assert(source != null);

    final String path = await _channel.invokeMethod(
      'pickVideo',
      <String, dynamic>{
        'source': source.index,
      },
    );
    return path == null ? null : File(path);
  }

  static Future<String> saveImage({@required Uint8List fileData, String title, String description}) async {
    assert(fileData != null);

    String  localIdentifier = await _channel.invokeMethod(
      'saveImage',
      <String, dynamic>{
        'fileData': fileData,
        'title': title,
        'description': description
      },
    );
    debugPrint("saved localIdentifier:" + localIdentifier);
    return  localIdentifier;
  }

}

